﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Reflection;
using ZXCompany.Models.Entity;
using ZXCompany.Models.Service;
namespace ZXCompany.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        ServiceFactory serfac = new ServiceFactory();        
        public ActionResult Index()
        {
            try
            {
                //ViewData["Message"] = "欢迎使用 ASP.NET MVC!";mainmenu_a/activemenu
                //网站首页
                ViewData["IndexTitleClass"] = "activemenu";
                //关于我们
                ViewData["AboutTitleClass"] = "mainmenu_a";
                //业务领域
                ViewData["BusinessTitleClass"] = "mainmenu_a";
                //解决方案
                ViewData["SolutionTitleClass"] = "mainmenu_a";
                //动态前沿
                ViewData["ActiveTitleClass"] = "mainmenu_a";
                //联系我们
                ViewData["ContUsTitleClass"] = "mainmenu_a";


                //获取首页显示的图片
                List<ZX_HomePageImage> lhpi = serfac.GetHomePageImageServie().GetHomePageImage();
                ViewData["HomePageImage"] = lhpi;
                return View();
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                return View("Error");
            }

        }
        /// <summary>
        /// 关于我们（公司介绍）
        /// </summary>
        /// <returns></returns>
        public ActionResult About()
        {
            try
            {
                //网站首页
                ViewData["IndexTitleClass"] = "mainmenu_a";
                //关于我们
                ViewData["AboutTitleClass"] = "activemenu";
                //业务领域
                ViewData["BusinessTitleClass"] = "mainmenu_a";
                //解决方案
                ViewData["SolutionTitleClass"] = "mainmenu_a";
                //动态前沿
                ViewData["ActiveTitleClass"] = "mainmenu_a";
                //联系我们
                ViewData["ContUsTitleClass"] = "mainmenu_a";

                //获取公司介绍
                ZXCompany.Models.Entity.ZX_CompanyInfo zxci = serfac.GetAboutService().GetCompanyInfo();
                ViewData["CompanyInfo"] = zxci;
                return View();
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return View("Error");
            }
           
        }
        /// <summary>
        /// 关于我们（经营理念）
        /// </summary>
        /// <returns></returns>
        public ActionResult RunIdea()
        {
            try
            {
                //网站首页
                ViewData["IndexTitleClass"] = "mainmenu_a";
                //关于我们
                ViewData["AboutTitleClass"] = "activemenu";
                //业务领域
                ViewData["BusinessTitleClass"] = "mainmenu_a";
                //解决方案
                ViewData["SolutionTitleClass"] = "mainmenu_a";
                //动态前沿
                ViewData["ActiveTitleClass"] = "mainmenu_a";
                //联系我们
                ViewData["ContUsTitleClass"] = "mainmenu_a";

                //获取经营理念数据
                ZXCompany.Models.Entity.ZX_RunIdea rid = serfac.GetAboutService().GetRunIdea();
                ViewData["RunIdea"] = rid;
                return View();
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return View("Error");
            }
        }

        /// <summary>
        /// 关于我们（总经理致辞）
        /// </summary>
        /// <returns></returns>
        public ActionResult ManagerSay()
        {
            try
            {
                //网站首页
                ViewData["IndexTitleClass"] = "mainmenu_a";
                //关于我们
                ViewData["AboutTitleClass"] = "activemenu";
                //业务领域
                ViewData["BusinessTitleClass"] = "mainmenu_a";
                //解决方案
                ViewData["SolutionTitleClass"] = "mainmenu_a";
                //动态前沿
                ViewData["ActiveTitleClass"] = "mainmenu_a";
                //联系我们
                ViewData["ContUsTitleClass"] = "mainmenu_a";
                //获取总经理致辞数据
                ZX_ManagerSpeak runidea = serfac.GetAccount().MSpeakSelect();
                ViewData["RunIdea"] = runidea;
                return View();
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return View("Error");
            }
        }

        /// <summary>
        /// 关于我们（专家团队）
        /// </summary>
        /// <returns></returns>
        public ActionResult ExpertTeam()
        {
            try
            {
                //网站首页
                ViewData["IndexTitleClass"] = "mainmenu_a";
                //关于我们
                ViewData["AboutTitleClass"] = "activemenu";
                //业务领域
                ViewData["BusinessTitleClass"] = "mainmenu_a";
                //解决方案
                ViewData["SolutionTitleClass"] = "mainmenu_a";
                //动态前沿
                ViewData["ActiveTitleClass"] = "mainmenu_a";
                //联系我们
                ViewData["ContUsTitleClass"] = "mainmenu_a";
                //专家团队信息
                List<ZX_ExpertType> lextype = serfac.GetAboutService().GetExpertType();
                ViewData["LExpertType"] = lextype;
                return View();
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return View("Error");
            }
        }
        /// <summary>
        /// 获取专家详细
        /// </summary>
        /// <returns></returns>
        public ActionResult ExpertDetail()
        {
            try
            {
                //网站首页
                ViewData["IndexTitleClass"] = "mainmenu_a";
                //关于我们
                ViewData["AboutTitleClass"] = "activemenu";
                //业务领域
                ViewData["BusinessTitleClass"] = "mainmenu_a";
                //解决方案
                ViewData["SolutionTitleClass"] = "mainmenu_a";
                //动态前沿
                ViewData["ActiveTitleClass"] = "mainmenu_a";
                //联系我们
                ViewData["ContUsTitleClass"] = "mainmenu_a";
                //专家团队信息
                int expertid = Convert.ToInt32(Request.QueryString["expertid"]);
                //获取专家信息
                ZX_ExpertInfo expertinfo = serfac.GetAboutService().GetExpertInfoById(expertid);
                //List<ZX_ExpertType> lextype = serfac.GetAboutService().GetExpertType();
                ViewData["ExpertInfo"] = expertinfo;
                return View();
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return View("ExpertTeam");
            }
        }
    }
}
